/**
 * Project: Utilities <br>
 * Package: org.leumasjaffe.builder
 */
package org.leumasjaffe.builder;

import org.eclipse.jdt.annotation.NonNullByDefault;

/**
 * Class org.leumasjaffe.builder..OnceConstructorBuilder in file OnceConstructorBuilder.java <br>
 * 
 * @author leumasjaffe
 * @version Jun 9, 2013
 * Created on: Jun 9, 2013
 * 
 * @param <T>
 * 
 */
@NonNullByDefault
public abstract class OnceDelegateBuilder<T> extends CheckedDelegateBuilder<T> implements OnceBuilder<T> {
	
	private T madeObject;

	/**
	 * @param constr
	 */
	@SuppressWarnings("null")
	protected OnceDelegateBuilder(int numArgs) {
		super(numArgs);
	}
	
	@Override
	public T build() {
		if (!alreadyBuilt()) {
			this.madeObject = super.build();
		}
		return this.madeObject;
	}

	/* (non-Javadoc)
	 * @see org.leumasjaffe.builder.OnceBuilder#alreadyBuilt()
	 */
	@Override
	public boolean alreadyBuilt() {
		return this.madeObject != null;
	}

}
